import java.util.ArrayList;

/**
 * Created by forcht on 2018/7/13.
 */
public class Solution {

    public ArrayList<ArrayList<Integer>> generate(int numRows) {
            ArrayList<ArrayList<Integer>> list=new ArrayList<>();
            for(int i=0;i<numRows;i++){
                ArrayList<Integer> a=new ArrayList<>();
                for (int j=0;j<=i;j++){
                    if (j==0||j==i){
                        a.add(1);
                    }else {
                        ArrayList<Integer> integers = list.get(i - 1);
                        a.add(integers.get(j)+integers.get(j-1));
                    }
                }
                list.add(a);
            }
            return list;
    }

    public static void main(String[] args) {
        Solution solution=new Solution();
        System.out.println(solution.generate(5));
    }
}
